package com.leil.fileserver.service;

import com.leil.fileserver.exception.FileOptException;
import com.leil.fileserver.properties.UploadProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.UUID;

@Service
public class VoiceUploadService extends UploadService {

    @Autowired
    UploadProperties uploadProperties;

    @Override
    public void initAllowSuffix() {
        this.allowSuffix = new String[]{".mp3"};
    }

    @Override
    public void initMaxSize() {
        this.maxSize = 10 * 1024 * 1024;
    }

    @Override
    public void initBucketName() {
        this.bucketName = this.uploadProperties.getVoiceBucket();
    }

    /**
     * 自定义附加的检查规则
     * @param file                  文件
     * @throws FileOptException
     */
    @Override
    public void checkFile(MultipartFile file) throws FileOptException {

    }

    @Override
    public String getFileName() {
        return this.getDateName();

    }

    @Override
    public String getPath() {
        return this.getDatePath();
    }
}
